"""插入排序"""

class InsertSort:
    def __init__(self,list_):
        self.list_ = list_
    def get_current_list(self):
        return self.list_
    def sort(self):
        list_ = self.list_
        for i in range (1,len(list_)):
            position = i
            current_value = list_[position]
            while position>0 and list_[position-1] > current_value:
                 list_[position] = list_[position-1]
                 position = position-1
            self.list_[position] = current_value
        return  self.list_
#
#
# list1 = InsertSort([1,6,3,7,9,5,2])
#
# print('list:',list1.get_current_list())
#
# list1.sort()
#
# print('sort result:',list1.get_current_list())